package edu.whu.webgis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.whu.webgis.entity.Likes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface LikeMapper extends BaseMapper<Likes> {
    @Select("select count(uid) from likes where uid = #{uid} and pid = #{pid}")
    Integer isExist(String uid, Integer pid);

    //未测试
    @Select("select title,nickname,likes from likes,user,posting where likes.uid = user.uid and likes.pid = posting.id and posting.uid = #{uid}")
    List<Map<String,Object>> getLikesByUid(Integer uid);

}
